function ModuleDialogSearchResult(doc, container, width, height, user, date, options, data) {
  this._doc = doc;
  this._container = container;
  this._width = width;
  this._height = height;
  this._user = user;
  this._date = date;
  this._options = options;
  this._data = data;
  
  this._item = (options && options.item) ? options.item : null;
  this._query = (options && options.query) ? options.query : '';
  this._popupBox = (options && options.popupBox) ? options.popupBox : null;
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : null;
  
  this._createElements();
};

ModuleDialogSearchResult.prototype._createElements = function() {
  var _self = this;
  this._gui = new DialogSearchResult(this._doc, this._container, this._width, this._height, this._user, this._date, this._options, this._data)._gui;

  tr = this._gui.mains.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.height = '24px';
  td.style.textAlign = 'left';
  td.style.padding = '5px 2px';
  td.appendChild(document.createTextNode('Loading...'));
  
  this._loadData();
};

ModuleDialogSearchResult.prototype._loadData = function() {
  this._results = null;
  this._retrieveUsers();
};

ModuleDialogSearchResult.prototype._verifyData = function() {
  if (this._results) {
    this._updateElements();
  }
};

ModuleDialogSearchResult.prototype._retrieveUsers = function() {
  var _self = this;
  var args = '&sql=' + encodeURIComponent(this._query);
  new RequestUtils()._mysql('findByRequest', args, function(result, params) { _self._results = result.data;
                                                                              _self._verifyData.call(_self);
                                                                            }, null);
};

ModuleDialogSearchResult.prototype._updateElements = function() {
  var tr, td, _self = this;
  
  DOMUtils.removeTableRows(this._gui.mains, 0);
  
  var results = []; exist = false;
  for (var i = 0, il = this._results.length; i < il; i++) {
    var object = this._results[i];
    for (attr in object) {
      for (var j = 0, jl = results.length; j < jl; j++) {
        var result = results[j];
        if (object[attr] == result) {
          exist = true;
        }
      }
      if (object[attr].toLowerCase().indexOf(this._item.value.toLowerCase()) != -1 && !exist) {
        results[results.length] = object[attr];
      }
    }
  }
  
  if (results.length == 0) {
    this._popupBox._close();
  } else {
    for (j = 0, jl = results.length; j < jl; j++) {
      var res = results[j];
      tr = this._gui.mains.insertRow(-1);
      td = tr.insertCell(-1);
      td.style.height = '24px';
      td.style.textAlign = 'left';
      td.style.padding = '5px 2px';
      td.style.cursor = 'default';
      
      var index = -1;
      if (res.toLowerCase().indexOf(this._item.value.toLowerCase()) != -1) {
        index = res.toLowerCase().indexOf(this._item.value.toLowerCase());
      }
      
      str0 = res.substring(0, index);
      str1 = res.substring(index, index + this._item.value.length);
      str2 = res.substring(index + this._item.value.length);
      
      span0 = document.createElement('span');
      span0.appendChild(document.createTextNode(str0));
      td.appendChild(span0);

      span1= document.createElement('span');
      span1.style.fontWeight = (index == -1) ? 'regular' : 'bold';
      span1.style.color = '#0000ff';
      span1.appendChild(document.createTextNode(str1));
      td.appendChild(span1);
    
      span2= document.createElement('span');
      span2.appendChild(document.createTextNode(str2));
      td.appendChild(span2);
      
      td._obj = res;
      td.onmouseover = function() {this.style.backgroundColor = '#f5ebe1';};
      td.onmouseout = function() {this.style.backgroundColor = '#fff';};
      td.onclick = function() { _self._item.value = this._obj;
                                _self._popupBox._close();
                                _self._callbackFunc();
                              };
    }
  }
  
};

